﻿package mortal.game.view.mainUI.Navbar
{
    import com.mui.utils.*;
    import extend.language.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.view.copy.groupCopy.view.*;
    import mortal.mvc.core.*;

    public class NavbarPackIcon extends NavbarBaseIcon
    {
        private var _numberBox:NumberBox;

        public function NavbarPackIcon()
        {
            return;
        }// end function

        override protected function addListerner() : void
        {
            super.addListerner();
            NetDispatcher.addCmdListener(ServerCommand.BackpackUpdateByVip, this.updateCapacity);
            NetDispatcher.addCmdListener(ServerCommand.BackpackAllDataGet, this.updateCapacity);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.updateCapacity);
            NetDispatcher.addCmdListener(ServerCommand.UpdateCapacity, this.updateCapacity);
            return;
        }// end function

        override protected function configUI() : void
        {
            super.configUI();
            return;
        }// end function

        public function updateCapacity(param1:Object) : void
        {
            if (Cache.instance.pack.backPackCache.leftCapacity <= 5)
            {
                if (this._numberBox == null)
                {
                    this._numberBox = UICompomentPool.getUICompoment(NumberBox);
                    this._numberBox.x = 20;
                    this.addChild(this._numberBox);
                }
                if (Cache.instance.pack.backPackCache.leftCapacity > 0)
                {
                    this._numberBox.text = Cache.instance.pack.backPackCache.leftCapacity.toString();
                }
                else
                {
                    this._numberBox.text = Language.getString(35364);
                }
            }
            else if (this._numberBox)
            {
                this._numberBox.dispose();
                this._numberBox = null;
            }
            return;
        }// end function

    }
}
